package com.ygxsk.carhome.ui.adapter;

import android.view.View;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.blankj.utilcode.util.ColorUtils;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.flyco.roundview.RoundTextView;
import com.ygxsk.carhome.R;
import com.ygxsk.carhome.enumwrap.AuthManageType;
import com.ygxsk.carhome.response.CarAttestation;
import com.ygxsk.carhome.utils.CommUtils;
import com.ygxsk.carhome.utils.StringCodeUtils;

import java.util.List;

/*
 * @Author:itchenqi175@163.com
 * @Time:2023-07-17  16:07
 * @Description:认证管理的 主页列表适配器
 */
public class AuthManageHistoryItemAdapter extends BaseQuickAdapter<CarAttestation, BaseViewHolder> {

    //填充一个代理进去,因为涉及到权限申请 放在activity之中用；
//    private BGANinePhotoLayout.Delegate bgaNinePhotoLayoutDelegate;
//
//    public void setBgaNinePhotoLayoutDelegate(BGANinePhotoLayout.Delegate _bgaNinePhotoLayoutDelegate) {
//        bgaNinePhotoLayoutDelegate = _bgaNinePhotoLayoutDelegate;
//    }

    public AuthManageHistoryItemAdapter(int layoutResId) {
        super(layoutResId);
    }

    public AuthManageHistoryItemAdapter(int layoutResId, @Nullable List<CarAttestation> data) {
        super(layoutResId, data);
        addChildClickViewIds(R.id.textvieweditviewphoneinauthhistory);
    }

    @Override
    protected void convert(@NonNull BaseViewHolder baseViewHolder, CarAttestation authManageItemBean) {

        if (authManageItemBean != null) {

            //姓名
            String name = authManageItemBean.getCustomerName();
            //手机号
            String phone = authManageItemBean.getCustomerPhone();
            //车辆型号
            String carModel = authManageItemBean.getCarModel();
            //认证的体系
            String authSystem = authManageItemBean.getAttestationNames();
            //状态的内容--主要是分配状态
            String satateItem = authManageItemBean.getStatusName();

            //findviews
            //姓名
            //评估的方式标签
            TextView textViewPersonName = (TextView) baseViewHolder.getView(R.id.textviewpersonnameinauthhistory);
            //手机号
            TextView textViewEditViewPhone = (TextView) baseViewHolder.getView(R.id.textvieweditviewphoneinauthhistory);
            //车辆型号
            TextView textViewCarModelValue = (TextView) baseViewHolder.getView(R.id.textviewcarmodelvalueauthhistory);
            //车辆评估认证的体系
            TextView textViewCarAuthSystem = (TextView) baseViewHolder.getView(R.id.textviewcarsystemvaluehistory);
            //底部的一个帮助布局
            TextView textViewHelpInAuthBottom = (TextView) baseViewHolder.getView(R.id.textviewhelpinauthbottom);

            //评估的方式标签
            RoundTextView textViewEvaluateFormWhere = (RoundTextView) baseViewHolder.getView(R.id.textviewauthstatehistory);
            //分配状态
//          TextView textViewPersonAuthState = (TextView) baseViewHolder.getView(R.id.textviewauthstate);

            int indexPosition = getItemPosition(authManageItemBean);
            if (indexPosition == getData().size() - 1) {
                textViewHelpInAuthBottom.setVisibility(View.VISIBLE);
            } else {
                textViewHelpInAuthBottom.setVisibility(View.GONE);
            }

            //具体的状态值
            int status = authManageItemBean.getStatus();

            //认证的边框
//            AuthManageType
//                    AUTH_TO_BE_CONTACTED(0, "待联系"), //待联系
//                    AUTH_TO_BE_CERTIFIED(1, "待认证"),//待认证
//                    AUTH_HAS_CERTIFIED(2, "已认证"),//已认证
//                    AUTH_HAS_CANCEL(3, "已取消");//已取消

            //【已认证】
            if (status == AuthManageType.AUTH_HAS_CERTIFIED.getIndex()) {

                //文字是绿色 边框是绿色
                textViewEvaluateFormWhere.getDelegate().setStrokeColor(ColorUtils.getColor(R.color.green_dark));
                textViewEvaluateFormWhere.getDelegate().setStrokePressColor(ColorUtils.getColor(R.color.green_dark));
                textViewEvaluateFormWhere.setTextColor(ColorUtils.getColor(R.color.green_dark));

            } else if (status == AuthManageType.AUTH_HAS_CANCEL.getIndex()) {

                //文字是红色 边框是红色
                textViewEvaluateFormWhere.getDelegate().setStrokeColor(ColorUtils.getColor(R.color.red));
                textViewEvaluateFormWhere.getDelegate().setStrokePressColor(ColorUtils.getColor(R.color.red));
                textViewEvaluateFormWhere.setTextColor(ColorUtils.getColor(R.color.red));

            }

            //该人员的状态：
            CommUtils.setText(textViewPersonName, name);
            //该人员的手机号
//            CommUtils.setText(textViewEditViewPhone, phone);
            CommUtils.setText(textViewEditViewPhone, StringCodeUtils.mobileEncrypt(phone));
            //该车辆的型号
            CommUtils.setText(textViewCarModelValue, carModel);
            //车辆的评估认证体系
            CommUtils.setText(textViewCarAuthSystem, authSystem);
            //该人员该车辆的状态
            CommUtils.setText(textViewEvaluateFormWhere, satateItem);

            //九宫格图片的查看信息：
//            npl_item_moment_photos_auth_detail.setData(imgs);
//            if (bgaNinePhotoLayoutDelegate!=null) {
//                npl_item_moment_photos_auth_detail.setDelegate(bgaNinePhotoLayoutDelegate);
//            }

        }

    }
}
